toPlot$SemYr<-as.factor(toPlot$SemYr)
toPlot <- toPlot[order(toPlot$SemYr),]
colors = rainbow(length(unique(toPlot$major)))
names(colors) = unique(toPlot$major)
plot_ly(toPlot, x = ~semester, y = ~ds_year, z = ~n, color = ~major, colors = colors) %>%
  add_markers() %>%
  layout(title = 'Major Distribution with respect to Time', scene = list(xaxis = list(title = 'Semester DS was taken'),
                     yaxis = list(title = 'Year DS was taken'),
                     zaxis = list(title = 'Number of Students')))